//****************************************************************************
//
// main.c
//
//****************************************************************************

#include "inc/hw_types.h"
#include "driverlib/rom.h"
#include "driverlib/sysctl.h"
#include "drivers/io.h"

#include "lineTracker.h"
#include "followLeader.h"
#include "lineIR.h"
#include "distanceIR.h"
#include "drive.h"
#include "wireless.h"
#include "helper.h"


#define LEADER
//#define FOLLOWER

#ifdef LEADER

//*****************************************************************************
// The main entry point for the leader.
//*****************************************************************************
int main (void)
{
    // Set the system clock to run at 50MHz from the PLL
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    // Initialize all the stuff used in the program.
    PushButtonsInit();
    DriveInit();
    HelperDisplayInit();
    LineIRInit();
    LineTrackerInit();

    CalibrateLineIR();

    WirelessInit();
    LeaderLink1();
    LeaderLink2();

    displayMessage("Final Project", "Line Tracker Leader");
    waitMiliSeconds(1000);

    while(true)
    {
    	TrackLine();
    }
}

#endif // end LEADER



#ifdef FOLLOWER

//*****************************************************************************
// The main entry point for the Follower.
//*****************************************************************************
int main (void)
{
    // Set the system clock to run at 50MHz from the PLL
    ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);

    // Initialize all the stuff used in the program.
    PushButtonsInit();
    DriveInit();
    DistanceIRInit();
    HelperDisplayInit();

    WirelessInit();
    FollowerLink();

    displayMessage("Final Project", "Line Tracker Follower");
    waitMiliSeconds(1000);

    while(true)
    {
    	FollowLeader();
    }
}

#endif
